<template>
	<view class="work-certificate">
		<view class="reject-box" v-if="form.status===3">
			<view class="flex-align-center">
				<static-image src="/pagesA/static/img/order/icon-notice.png" width="40" height="40" margin-right="16"></static-image>
				<view class="font-s-16 fw-b">拒绝原因</view>
			</view>
			<view class="color-666 line-height-44 mar-t-15">{{form.approveRemark || '暂无拒绝原因'}}</view>
		</view>
		<view class="form-card-box">
			<view class="form-box">
				<view class="flex-align-center">
					<view class="fw-b">工作单位</view>
					<view class="mar-l-24 flex-1">
						<u-input :disabled="[1,2].includes(form.status)" v-model="form.workUnit" placeholder="请填写您所在单位名称"></u-input>
					</view>
				</view>
				<view class="flex-align-center">
					<view class="fw-b">从业岗位</view>
					<view class="mar-l-24 flex-1">
						<u-input :disabled="[1,2].includes(form.status)" v-model="form.jobPosition" placeholder="请填写您的工作岗位"></u-input>
					</view>
				</view>
				<view class="flex-align-center">
					<view class="fw-b">入职年薪</view>
					<view class="mar-l-24 flex-1 flex-align-center">
						<u-input :disabled="[1,2].includes(form.status)" class="flex-1" v-model="form.entryAnnualSalary" type="number" placeholder="请输入"></u-input>
						<text class="mar-l-15 color-666">万元</text>
					</view>
				</view>
			</view>
		</view>
		<view class="form-card-box" style="padding: 32rpx 24rpx 12rpx;">
			<view class="font-s-14 fw-b">证明材料</view>
			<view class="img-box" v-if="[1,2].includes(form.status)">
				<view v-for="(item,index) in photos" :key="index" class="pic-item">
					<u-image :src="item" width="200" height="200" border-radius="8" @click="$common.previewImage(photos,index)"></u-image>
				</view>
			</view>
			<view class="mar-t-15 flex-between-center" v-else>
				<image-upload v-model="form.companyFrontDeskPhoto" max-count="1" uploadText="公司前台照"></image-upload>
				<image-upload v-model="form.personalWorkstationPhoto" max-count="1" uploadText="个人工位照"></image-upload>
				<image-upload v-model="form.personalWorkIdPhoto" max-count="1" uploadText="个人工牌照"></image-upload>
			</view>
		</view>
		<footer-btn v-if="form.status!==2">
			<u-button v-if="form.status===1" hover-class="none" shape="circle" type="primary" :custom-style="{background:'#F5F7FA',color:'#999999',fontSize:'32rpx',fontWeight:'bold',height:'90rpx',letterSpacing: '8rpx'}">正在审核中</u-button>
			<u-button v-else :disabled="btnDisabled" shape="circle" @click="confirm()" type="primary" :custom-style="{background:'#1F78FF',fontSize:'32rpx',fontWeight:'bold',height:'90rpx',letterSpacing: '8rpx'}">确认提交</u-button>
		</footer-btn>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				form: {},
				photos: []
			}
		},
		computed:{
			btnDisabled(){
				return !this.form.workUnit || !this.form.jobPosition || !this.form.entryAnnualSalary || !this.form.companyFrontDeskPhoto || !this.form.personalWorkstationPhoto || !this.form.personalWorkIdPhoto
			}
		},
		onLoad() {
			this.getDetail()
		},
		methods: {
			getDetail() {
				this.$request({
					url: '/orderInfoIncrIncome/incrWorkProveDetail',
					method: 'get',
				}).then(res => {
					this.form = res.data || {}
					if(res.data){
						this.photos = [JSON.parse(this.form.companyFrontDeskPhoto)[0].url,JSON.parse(this.form.personalWorkstationPhoto)[0].url,JSON.parse(this.form.personalWorkIdPhoto)[0].url]
					}
				})
			},
			confirm(){
				uni.showLoading({ mask:true })
				this.$request({
					url: '/orderInfoIncrIncome/saveIncrWorkProve',
					method: 'post',
					data: this.form
				}).then(res => {
					this.$u.toast('提交成功');
					this.$common.handleSuccess()
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.work-certificate {
		background-image: url('../static/img/quota/work-header-bg.png');
		background-size: 100% 480rpx;
		background-repeat: no-repeat;
		padding: 232rpx 24rpx 0;
		.img-box{
			display: flex;
			justify-content: space-between;
			margin-top: 30rpx;
			>view{
				margin: 0 24rpx 24rpx 0;
				&:nth-child(3n){
					margin-right: 0;
				}
			}
		}
		.form-card-box{
			background: #FFFFFF;
			border-radius: 24rpx;
			padding: 0 24rpx;
			margin-bottom: 24rpx;
			::v-deep.u-list-item{
				margin-right: 0;
			}
		}
		.form-box{
			.mar-l-24{
				margin-left: 48rpx;
			}
			>view{
				height: 108rpx;
				&:not(:last-child){
					border-bottom: 2rpx solid #f5f5f5;
				}
			}
		}
	}
</style>
